﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;

namespace OnlineLogCommon
{
    public class SocketTcpClient : IDisposable
    {
        private Socket _Socket;
        public void Connect(string host, int port)
        {
            if (_Socket == null)
            {
                _Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                _Socket.Connect(host, port);
            }
        }
        public void Send(string msg)
        {
            byte[] sendbuffers = Encoding.UTF8.GetBytes(msg);
            var xx = _Socket.Send(sendbuffers);
        }

        public void Dispose()
        {
            if (_Socket != null)
                _Socket.Dispose();
            _Socket = null;
        }
    }
}
